/**
 * 
 */
package com.cater.sys.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cater.common.BaseEntity;
import com.cater.common.PageResult;
import com.cater.query.CommonQuery;
import com.cater.sys.dao.ContactDao;
import com.cater.sys.service.BaseService;
import com.cater.talents.entity.Contact;

/**
 * @Description: TODO
 * @author: yong
 * @time:2018年3月25日 上午12:28:47
 */
@Service
public class ContactServiceImpl implements BaseService<Contact, CommonQuery, String> {
	@Autowired
	ContactDao dao;

	@Override
	public PageResult<Contact> findPageResult(CommonQuery query) {
		PageResult<Contact> result = new PageResult<Contact>();
		result.setPage(query.getPage());
		result.setPageSize(query.getRows());
		int count = dao.findCount(query);
		int first = (query.getPage() - 1) * query.getRows();
		int max = query.getRows();
		List<Contact> list = dao.findList(query, first, max);
		result.setRows(list);
		result.setRecords(count);
		return result;
	}

	@Override
	public List<Contact> getAll() {
		return dao.getAll();
	}

	@Override
	public List<Contact> getAllCommon(CommonQuery query) {
		return dao.getAllCommon(query);
	}

	@Override
	public int save(Contact t) {
		return 0;
	}

	@Override
	public String saves(Contact t) {
		BaseEntity.getCreate(t);
		dao.save(t);
		return t.getCompanyId();
	}

	@Override
	public void update(Contact t) {
		BaseEntity.getupdate(t);
		dao.update(t);
	}

	@Override
	public void delete(String id) {
		dao.delete(id);
	}

	@Override
	public Contact getById(String id) {
		return dao.getById(id);
	}

	public List<Contact> getContactList(String companyId, String contactId) {
		return dao.getContactList(companyId, contactId);
	}
	
	public Contact getContactBy(String companyId, String contactId) {
		return dao.getContactBy(companyId, contactId);
	}
	
	public void deleteUR(String companyId, String contactId) {
		dao.deleteUR(companyId, contactId);
	}
}
